###参考 artisan make:model 而写的 make:view 新建blade模版
- MakeView.php - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 namespace App\Console\Commands;
 use Illuminate\Console\Command;
 use Illuminate\Filesystem\Filesystem;
 class MakeView extends Command
 {
 /**
 * The name and signature of the console command.
 *
 * @var string
 */
 protected $signature = 'make:view {name : like content or article/content}';
 /**
 * The console command description.
 *
 * @var string
 */
 protected $description = 'Create a new blade page';
 /**
 * The type of class being generated.
 *
 * @var string
 */
 protected $type;
 /**
 * 文件系统
 * @var Filesystem
 */
 protected $files;
 /**
 * Create a new command instance.
 *
 * @return void
 */
 public function __construct(Filesystem $files)
 {
 parent::__construct();
 $this->files=$files;
 }
 /**
 * Execute the console command.
 *
 * @return mixed
 */
 public function handle()
 {
 //
 $path = $this->getPath($this->argument('name'));
 if($this->alreadyExists($path)){
 $this->error($this->type.' already exists!');
 return false;
 }
 $this->makeDir($path);
 $this->files->put($path, $this->getStub());
 return $this->info($this->type.' created successfully.');
 }
 /**
 * Get path
 * @param string $name
 * @return string
 */
 protected function getPath($name){
 return base_path('resources/views')."/".$name.".blade.php";
 }
 /**
 * 模版是否已经存在
 * @param $path
 * @return bool
 */
 protected function alreadyExists($path){
 return $this->files->exists($path);
 }
 /**
 * 建立目录
 * @param $path
 */
 protected function makeDir($path){
 if (! $this->files->isDirectory(dirname($path))) {
 $this->files->makeDirectory(dirname($path), 0777, true, true);
 }
 }
 /**
 * 获得模版内容
 * @param string $stub //现在默认为bootstrap风格 以后还可以添加妹子UI风格模版等等
 * @return string
 * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
 */
 protected function getStub($stub='view.stub'){
 return $this->files->get(__DIR__.'/stubs/'.$stub);
 }
 }
- view.stub - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 <html lang="en">
 <head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <meta http-equiv="x-ua-compatible" content="ie=edge">
 <title>New Page</title>
 <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
 <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
 <script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
 </head>
 <body>
 </body>
 </html>
##注意
想要自定义参数 比如短参数必须使用两个方法 getArguments() 和 getOptions()
###补充
又看了遍源码 找到更方便的方法 这个文档里没有写 所以下面两种方法都可以
| 1 | //直接设置属性就可以了 切记短参数放在前面用 | 分割 | 
| 1 | 
 | 
 
          
          
          
         
     
          
         
          
        